import React, { Component } from "react";
import Main from "./c-cnps/Main.jsx";
import Maincount from "./c-cnps/Maincount.jsx";

export default class App extends Component {
  constructor() {
    super()
    this.state = {
      count: 100
    }
  }
  change(num){
    const { count } = this.state
    this.setState({
      count: count + num
    })
  }
  render() {
    const { count } = this.state
    return (
      <div>
        <Main></Main>
        <h1>{count}</h1>
        { /* 传递函数用于子组件向父组件通信 */ }
        <Maincount changeCount={(count) => this.change(count)}/>
      </div>
    );
  }
}
